#include "StdAfx.h"
#include "CCommandVariable.h"
#include "IConsoleScreen.h"
#include "CArgumentList.h"
#include "CValue.h"

CConsoleVariable::CConsoleVariable( const csString & strName, IValue & value, 
								   const csString & strHelp ) 
: CCommand(strName, strHelp)
, m_Value(value)
{

}


bool CConsoleVariable::Execute( IConsoleScreen *pScreen, const CArgumentList & args )
{
	if ( 1 == args.GetSize() )
	{
		pScreen->PrintVerbose( "insert " + args[0] + " to " + GetCommandName() );
		m_Value.Set( args[0] );
		return true;
	}

	pScreen->Print( "usage         : " + GetCommandName() + " <value>" );
	pScreen->Print( "desc          : " + GetCommandDesc() );
	pScreen->Print( "default value : " + m_Value.Default() );
	pScreen->Print( "current value : " + m_Value.Get() );
	return true;

}

CConsoleVariable::~CConsoleVariable()
{

}
